package com.cilico.single.view;

import android.content.Context;
import android.view.Gravity;
import android.view.View;
import android.widget.LinearLayout;

import com.cilico.single.components.Component;
import com.cilico.single.components.CssStyle;
import com.cilico.single.utils.Utils;

/**
 * Segment控件
 * 
 * @author lv.xiangan
 *
 */
public class SegmentLinearLayout extends LinearLayout implements Component {
	// 单�?按钮segment总数，主要用于计数带有segment属�?的单选按钮个�?
	public String segMentName_;
	// 是否已被添加至界面管理器标志
	public boolean isAdded_;
	private int height_;
	private int width_;
	private LinearLayout selfLayout_;
	protected CssStyle cssStyle_;

	public SegmentLinearLayout(Context context, String segmentname) {
		super(context);
		// TODO Auto-generated constructor stub
		// 设置该控件内元素排列方式为横向排�?
		setOrientation(LinearLayout.HORIZONTAL);
		// 设置元素对其方式为居�?
		setGravity(Gravity.CENTER);
		segMentName_ = segmentname;
		isAdded_ = false;
		LinearLayout.LayoutParams lop = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
		setLayoutParams(lop);
	}

	public void cleanText() {
		// TODO Auto-generated method stub

	}

	public String getContentText() {
		// TODO Auto-generated method stub
		return null;
	}

	public View getCmpView() {
		if (selfLayout_ != null) {
			return selfLayout_;
		}
		return this;
	}

	public void mould() {
		// TODO Auto-generated method stub
		try {
			final int size = this.getChildCount();
			for (int i = 0; i < size; i++) {
				Component c = (Component) this.getChildAt(i);
				c.mould();
			}

			LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(width_, height_);
			if (selfLayout_ != null) {
				BaseView.removeViewsStepByStep(selfLayout_, this);
			}
			selfLayout_ = BaseView.createSelfLayout(this.getContext(), lp, cssStyle_, this);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			Utils.printException(e);
		}
	}

	public void setContentText(String text) {
		// TODO Auto-generated method stub

	}

	public void setCssStyle(CssStyle style) {
		// TODO Auto-generated method stub
		cssStyle_ = style;
	}

	public void setCmpHeidht(int height) {
		// TODO Auto-generated method stub
		height_ = height;
	}

	public void setCmpWidth(int width) {
		// TODO Auto-generated method stub
		width_ = width;
	}

	public void shrinkWidth() {
		// TODO Auto-generated method stub

	}

	public int getCmpHeight() {
		return height_;
	}

	public int getCmpWidth() {
		return 0;
	}

	public void setInTable(boolean inTable) {
	}

	public boolean isInTable() {
		return false;
	}

	public CssStyle getCssStyle() {
		return null;
	}

	public void releaseResource(View view) {
		// TODO Auto-generated method stub
		Utils.releaseResource(view);
	}

	public void setForm(FormLayout formLayout) {
		// TODO Auto-generated method stub
	}

	public FormLayout getForm() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void setEncrypt(String encrypt) {
		// TODO Auto-generated method stub

	}

}
